package com.wish233.wiliwilivideo.controller;

import com.wish233.wiliwilicommon.common.BaseResponse;
import com.wish233.wiliwilicommon.common.ErrorCode;
import com.wish233.wiliwilicommon.common.ResultUtils;
import com.wish233.wiliwilicommon.exception.BusinessException;
import com.wish233.wiliwilicommon.exception.ThrowUtils;
import com.wish233.wiliwilivideo.service.VideoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author WHH
 */
@RestController
@RequestMapping()
public class UserVideoController {

    @Resource
    private VideoService videoService;

    @PostMapping("/addViewCount/{id}")
    @ApiOperation("增加视频播放量")
    public BaseResponse<Boolean> addViewCount(@PathVariable Long id) {
        ThrowUtils.throwIf(id == null, new BusinessException(ErrorCode.PARAMS_ERROR));
        return ResultUtils.success(videoService.addViewCount(id));
    }
}
